/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Issam
 */
@Entity
@Table(name = "CLIENT", catalog = "", schema = "NETTRADING")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Client.findAll", query = "SELECT c FROM Client c"),
    @NamedQuery(name = "Client.findByNom", query = "SELECT c FROM Client c WHERE c.nom = :nom"),
    @NamedQuery(name = "Client.findByPrenom", query = "SELECT c FROM Client c WHERE c.prenom = :prenom"),
    @NamedQuery(name = "Client.findByAdresse", query = "SELECT c FROM Client c WHERE c.adresse = :adresse"),
    @NamedQuery(name = "Client.findByTelephone", query = "SELECT c FROM Client c WHERE c.telephone = :telephone"),
    @NamedQuery(name = "Client.findByEmail", query = "SELECT c FROM Client c WHERE c.email = :email"),
    @NamedQuery(name = "Client.findByProfession", query = "SELECT c FROM Client c WHERE c.profession = :profession")})
public class Client implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @Column(name = "NOM", nullable = false, length = 20)
    private String nom;
    @Basic(optional = false)
    @Column(name = "PRENOM", nullable = false, length = 20)
    private String prenom;
    @Basic(optional = false)
    @Column(name = "ADRESSE", nullable = false, length = 40)
    private String adresse;
    @Basic(optional = false)
    @Column(name = "TELEPHONE", nullable = false)
    private int telephone;
    @Id
    @Basic(optional = false)
    @Column(name = "EMAIL", nullable = false, length = 30)
    private String email;
    @Basic(optional = false)
    @Column(name = "PROFESSION", nullable = false, length = 30)
    private String profession;
    @JoinColumn(name = "MATRICULE", referencedColumnName = "MATRICULE", nullable = false)
    @ManyToOne(optional = false)
    private Trader matricule;
    @JoinColumn(name = "ID_ENTREPRISE", referencedColumnName = "ID_ENTREPRISE")
    @ManyToOne
    private Entreprise idEntreprise;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "email")
    private Collection<OrdreVente> ordreVenteCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "email")
    private Collection<Portefeuille> portefeuilleCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "email")
    private Collection<OrdreAchat> ordreAchatCollection;

    public Client() {
    }

    public Client(String email) {
        this.email = email;
    }

    public Client(String email, String nom, String prenom, String adresse, int telephone, String profession) {
        this.email = email;
        this.nom = nom;
        this.prenom = prenom;
        this.adresse = adresse;
        this.telephone = telephone;
        this.profession = profession;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public String getAdresse() {
        return adresse;
    }

    public void setAdresse(String adresse) {
        this.adresse = adresse;
    }

    public int getTelephone() {
        return telephone;
    }

    public void setTelephone(int telephone) {
        this.telephone = telephone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getProfession() {
        return profession;
    }

    public void setProfession(String profession) {
        this.profession = profession;
    }

    public Trader getMatricule() {
        return matricule;
    }

    public void setMatricule(Trader matricule) {
        this.matricule = matricule;
    }

    public Entreprise getIdEntreprise() {
        return idEntreprise;
    }

    public void setIdEntreprise(Entreprise idEntreprise) {
        this.idEntreprise = idEntreprise;
    }

    @XmlTransient
    public Collection<OrdreVente> getOrdreVenteCollection() {
        return ordreVenteCollection;
    }

    public void setOrdreVenteCollection(Collection<OrdreVente> ordreVenteCollection) {
        this.ordreVenteCollection = ordreVenteCollection;
    }

    @XmlTransient
    public Collection<Portefeuille> getPortefeuilleCollection() {
        return portefeuilleCollection;
    }

    public void setPortefeuilleCollection(Collection<Portefeuille> portefeuilleCollection) {
        this.portefeuilleCollection = portefeuilleCollection;
    }

    @XmlTransient
    public Collection<OrdreAchat> getOrdreAchatCollection() {
        return ordreAchatCollection;
    }

    public void setOrdreAchatCollection(Collection<OrdreAchat> ordreAchatCollection) {
        this.ordreAchatCollection = ordreAchatCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (email != null ? email.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Client)) {
            return false;
        }
        Client other = (Client) object;
        if ((this.email == null && other.email != null) || (this.email != null && !this.email.equals(other.email))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "test.entities.Client[ email=" + email + " ]";
    }
    
}
